import IUserPageForm from '@/model/form/user/IUserPageForm'
import IPageVO from '@/model/vo/common/IPageVO'
import IResVO from '@/model/vo/common/IResVO'
import IUserPageVO from '@/model/vo/user/IUserPageVO'
import $http from '@/util/http'
import { AxiosResponse } from 'axios'

// 分页排序查询：用户
export default function userPageApi(form: IUserPageForm) {
  if (!form.orderList) {
    form.orderList = []
  }

  // 在排序最后追加根据更新时间倒序
  form.orderList = [
    ...form.orderList,
    { name: 'a.update_time', value: 'descend' },
  ]

  return $http.post<
    IResVO,
    AxiosResponse<IResVO<IPageVO<IUserPageVO>>>,
    IUserPageForm
  >('/user/page', form)
}
